package com.dd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dd.entity.Employees;
import com.dd.entity.PageResult;
import com.dd.entity.dto.EmployeeQueryDTO;
import com.dd.mapper.EmployeesMapper;
import com.dd.service.IEmployeesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author dhd
 * @since 2024-12-09 10:44
 */
@Service
public class EmployeesServiceImpl extends ServiceImpl<EmployeesMapper, Employees> implements IEmployeesService {
    @Autowired
    EmployeesMapper employeesMapper;
    @Override
    public PageResult<Employees> getPage(EmployeeQueryDTO employeeQueryDTO) {
        Page page = new Page<>(employeeQueryDTO.getPageNum(),employeeQueryDTO.getPageSize());
        QueryWrapper<Employees> queryWrapper = new QueryWrapper();
        if (StringUtils.isNotEmpty(employeeQueryDTO.getEmpName())){
            queryWrapper.like("emp_Name",employeeQueryDTO.getEmpName());
        }

        queryWrapper.lt("salary",employeeQueryDTO.getSalary());

        IPage<Employees> employeesIPage = employeesMapper.selectPage(page,queryWrapper);
        return PageResult.of(employeesIPage);
    }
}

